<?php 

define('PATH', dirname(dirname(__FILE__)).'/');
require_once(PATH . '../../../wp-blog-header.php');
global $wpdb;

$url = $_REQUEST['url'];


 if($url!=''){
	 // //$sql = "DELETE FROM $wpdb->term_relationships WHERE object_id in (".$pro.") AND term_taxonomy_id  in (SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id in (".$cat.") and taxonomy = 'category');";
	// //$wpdb->query($sql);	
	// //echo "<script>alert('提示内容')</script>";

  $ch = curl_init();//初始化一个cURL会话
  curl_setopt($ch ,CURLOPT_URL ,$url);//设置 URL
  curl_setopt($ch ,CURLOPT_HEADER ,0);//是否返回头信息
  curl_setopt($ch ,CURLOPT_RETURNTRANSFER ,1);//将curl_exec()获取的信息以字符串返回，而不是直接输出
  $str = curl_exec($ch);//返回字符串
  curl_close($ch);//释放资源

//$html = file_get_html($url);

	include('simple_html_dom/simple_html_dom.php');//引入类库文件
		// 创建一个DOM对象
		 $html = new simple_html_dom();

		// 载入html字符串
		 $html->load($str); 	
		$info["company_name"] = $html->find('input[id=company_name]',0)->value; 
		$info["address"] = $html->find('input[id=address]',0)->value;
		$info["email"] = $html->find('input[id=email]',0)->value;
		$info["phone"] = $html->find('input[id=phone]',0)->value;
		$info["phone02"] = $html->find('input[name="telephone"]',0)->value;
		$info["email02"] = $html->find('input[id=email]',0)->value;
		$info["fax"] = $html->find('input[name=fax]',0)->value;
		$info["whatsapp"] = $html->find('input[name=whatsapp]',0)->value;
		
	
		echo $info;	
		
		updateInfo("root","qqs","123456",$info); 
}
 
 
function updateInfo($user,$db,$pw,$info){
$con=mysqli_connect("localhost",$user,$pw,$db);
// 检测链接
if (mysqli_connect_errno($con))
{
    echo "连接到 MySQL 失败: " . mysqli_connect_error();
} 
$sql = "UPDATE wp_postmeta SET meta_value = '".$info[0]->company_name."' WHERE post_id = 50 and meta_key = 'lianxi_company';";
$sql =$sql . "UPDATE wp_postmeta SET meta_value = '".$info[0]->address."' WHERE post_id = 50 and meta_key = 'lianxi_adress';";
$sql =$sql . "UPDATE wp_postmeta SET meta_value = '".$info[0]->email."' WHERE post_id = 50 and meta_key = 'lianxi_mail_01';";
$sql =$sql . "UPDATE wp_postmeta SET meta_value = '".$info[0]->phone."' WHERE post_id = 50 and meta_key = 'lianxi_phone_01';";
$sql =$sql . "UPDATE wp_postmeta SET meta_value = '".$info[0]->email02."' WHERE post_id = 50 and meta_key = 'lianxi_mail_02';";
$sql =$sql . "UPDATE wp_postmeta SET meta_value = '".$info[0]->phone02."' WHERE post_id = 50 and meta_key = 'lianxi_phone_02';";
$sql =$sql . "UPDATE wp_postmeta SET meta_value = '".$info[0]->fax."' WHERE post_id = 50 and meta_key = 'lianxi_fax';";
$sql =$sql . "UPDATE wp_postmeta SET meta_value = '".$info[0]->whatsapp."' WHERE post_id = 50 and meta_key = 'lianxi_whatsapp';";
var_dump($sql);
mysqli_multi_query($con,$sql);
mysqli_close($con);
}




?>